var config = {
    vx: 4, //小球x轴速度,正为右，负为左
    vy: 4, //小球y轴速度
    height: 2, //小球高宽，其实为正方形，所以不宜太大
    width: 2,
    count: 200, //点个数
    // color: "121, 162, 185", 	//点颜色
    color: "200,193,193", //点颜色
    // stroke: "130,255,255", 		//线条颜色
    // stroke: "240,250,228", 		//线条颜色
    stroke: "0,0,0", //线条颜色
    dist: 6000, //点吸附距离
    e_dist: 20000, //鼠标吸附加速距离
    max_conn: 10 //点到点最大连接数
}

//调用
CanvasParticle(config);

/* 需求：楼层滚动。点击相应楼层，滚动到相应的页面位置 */

$a('.uzi').forEach(function(v, i) {
    // console.log(v);
    v.addEventListener('click', function() {
        $a('.uzi').forEach(function(value, index) {
            $a('.tiao')[index].style.display = 'none';

        })
        $a('.tiao')[i].style.display = 'block';

    })

})


/* 楼层滚动效果 */
let bx = document.querySelectorAll(".bx")
let lis = document.querySelectorAll('.uzi')
for (let i = 0; i < lis.length; i++) {
    const li = lis[i]
    li.onclick = function(e) {
        //页面的偏移量，原来的页面滚动的距离
        let scrollTop = document.documentElement.scrollTop
        let offsetTop = bx[i].offsetTop
        if (scrollTop > offsetTop) {
            // 滚动条向上移动
            let timer = setInterval(function() {
                if (scrollTop > offsetTop) {
                    scrollTop -= 40
                    if (scrollTop - offsetTop < 40) {
                        // 如果最后一洞的距离小于40时，直接设置偏移量为0
                        window.scrollTo(0, offsetTop)
                    } else {
                        window.scrollTo(0, scrollTop)
                    }
                } else {
                    clearInterval(timer)
                }
            }, 50)
        } else {
            // 滚动条向下移动
            // scrollTop <= offsetTop
            let timer = setInterval(function() {
                if (scrollTop < offsetTop) {
                    scrollTop += 40
                    if (offsetTop - scrollTop < 40) {
                        window.scrollTo(0, offsetTop)
                    } else {
                        window.scrollTo(0, scrollTop)
                    }
                } else {
                    clearInterval(timer)
                }
            }, 50);


        }

    }
}